package com.itheima.d1_collection_set;

import java.util.HashMap;
import java.util.HashSet;
import java.util.function.Consumer;

/*
     目标：自定义的类型的对象，比如两个内容一样的学生对象，如果让HashSet集合能够去重复！
 */
public class SetTest3 {
    public static void main(String[] args) {
        HashSet<Student> stu = new HashSet<>();
        stu.add(new Student("小明",321));
        stu.add(new Student("小明",31));
        stu.add(new Student("小明",21));
        stu.add(new Student("小明",321));
        stu.add(new Student("小明",321));
        stu.add(new Student("小明",321));
        stu.add(new Student("小明",321));

        for(Student st:stu){
            System.out.println(st.getName()+" "+st.getAge());
        }

        stu.forEach(new Consumer<Student>() {
            @Override
            public void accept(Student student) {
                System.out.println(student.getName());
            }
        });


    }
}
